import { observer } from 'mobx-react';
import { toJS } from 'mobx'
import { WeaLocaleProvider } from 'ecCom'
import { WeaTableNew } from 'comsMobx'
const getLabel = WeaLocaleProvider.getLabel;
const WeaTable = WeaTableNew.WeaTable;

@observer
export default class GovernShare extends React.Component {

    constructor(props) {
        super(props);
    }

    componentDidMount = () => {
        const { governShareStore, id } = this.props;
        governShareStore.setId({ id });
        governShareStore.getShareList();
        governShareStore.ShowMessage(false)
    }
    componentWillUnmount(){
        this.props.governShareStore.ShowMessage(true)
    }
    render() {
        const { governShareStore } = this.props;
        const { tableStoreMyAttent } = governShareStore;
        return (
            <div className='prj-query'>
                <div>
                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@85i8jn`}
                        comsWeaTableStore={tableStoreMyAttent}
                        hasOrder={true}
                        needScroll={true}
                        getColumns={c => this.reRenderColumns(c)}
                    />
                </div>
            </div>
        )
    }

    reRenderColumns(columns) {
        columns.forEach(c => {
            if (c.dataIndex == 'finish') {
                c.render = function (text, record) {
                    return <span className='wea-prj-progressStyle' >
                        <WeaProgress ecId={`${this && this.props && this.props.ecId || ''}_WeaProgress@1470i9@${c.dataIndex}`} percent={record.finish || 0} strokeColor={record.finishspan} />
                    </span>
                }
            } else {
                c.render = function (text, record) {
                    let valueSpan = record[c.dataIndex + "span"] !== undefined ? record[c.dataIndex + "span"] : record[c.dataIndex];
                    return <span dangerouslySetInnerHTML={{ __html: valueSpan }}></span>
                }
            }
        })
        return columns;
    }
}